﻿using Dyao.Book.Contract;
using Dyao.Book.Entity;
using Dyao.Book.Repository.Abstractions;

namespace Dyao.Repository.Abstractions
{
    public interface ITaskCenterRecordRepository : IDataRepository<TaskCenterRecordEntity, int>
    {
        /// <summary>
        /// 获取重试列表
        /// </summary>
        /// <param name="pageIndex">pageIndex</param>
        /// <param name="pageSize">pageSize</param>
        /// <param name="cancellationToken">cancellationToken</param>
        /// <returns></returns>
        Task<List<TaskCenterRecordEntity>> GetNeedRetryListAsync(int pageIndex, int pageSize, CancellationToken cancellationToken = default);

        /// <summary>
        /// 获取超时列表
        /// </summary>
        /// <param name="pageIndex">pageIndex</param>
        /// <param name="pageSize">pageSize</param>
        /// <param name="cancellationToken">cancellationToken</param>
        /// <returns></returns>
        Task<List<TaskCenterRecordEntity>> GetTimeoutListAsync(int pageIndex, int pageSize, CancellationToken cancellationToken = default);

        /// <summary>
        /// 获取已完成状态的任务记录Id列表 用于删除
        /// </summary>
        /// <param name="recordTypeEnum">记录类型</param>
        /// <param name="maxDateTime"></param>
        /// <param name="num">数量</param>
        /// <param name="cancellationToken"></param>
        /// <returns>记录数据主键Id列表</returns>
        Task<List<int>> GetCompleteTaskRecordIdListForDeleteAsync(DeleteRecordTypeEnum recordTypeEnum, DateTime maxDateTime, int num = 500, CancellationToken cancellationToken = default);

        /// <summary>
        /// 根据属性名更新属性值
        /// </summary>
        /// <param name="task">任务</param>
        /// <param name="propertyNames">属性名称</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns></returns>
        Task UpdateByPropertyNameAsync(TaskCenterRecordEntity task, string[] propertyNames, CancellationToken cancellationToken = default);
    }
}